<#if id?has_content>
<@cms.comment id=id>
	<#assign text=object.text!/>
</@cms.comment>
</#if>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<title>评论 - ${content.title}</title>
	<meta name="keywords" content="<#list getKeywords(content.title) as a>${a}<#sep>,</#list>"/>
	<meta name="description" content="${content.description}"/>
	<@tools.includePlace path="/76c53ac2-4f88-4ef3-984b-c81d00a48089.html"/> <#-- 头部Header -->
</head>
<body>
	<@tools.includePlace path="/23e95a91-0063-4498-99ef-aa3fc4a79c4c.html"/> <#-- 导航 -->
	<main>
		<div class="container clearfix-after">
			<@tools.includePlace path="/c936c718-5f19-426f-b3ff-13a5a8d63044.html"/> <#-- 个人中心导航 -->
			<div class="right-content">
				<div class="box">
					<h1><a href="${content.url!}">${content.title}</a></h1>
					<p>${content.description!}</p>
					<div>
						${content.scores!} 赞
						<#if user?has_content>
							<@cms.userScore userId=user.id itemType='content' itemId=content.id>
								<a href="javascript:unstar(${content.id});">取消点赞</a>
								<#assign stared=true/>
							</@cms.userScore>
							<#if !stared?has_content><a href="javascript:star(${content.id});">点赞</a></#if>
						</#if>
					</div>
					<@import path="ftl/tools.ftl" namespace="t"/>
					<#if error?has_content>
					<p style="color:red"><@t.m error/></p>
					</#if>
					<div class="comment-box">
						<#if user?has_content>
							<#if !pageIndex?has_content || pageIndex=1>
								<p>发布评论：<span class="float-right"><a href="${site.dynamicPath}member/login.html?returnUrl=${content.url?url}">${(user.nickname)!}</a></span></p>
								<div class="comment-text-box user-logout">
									<form method="post" action="${site.dynamicPath}comment/save">
										<input type="hidden" name="id" value="${id!}"/>
										<#if replyId?has_content>
										<p class="reply"><@cms.comment id=replyId><span class="username">@<@sys.user id=object.userId>${object.nickname}</@sys.user></span> : ${object.text!}</@cms.comment></p>
										<input type="hidden" name="replyId" value="${replyId!}"/>
										</#if>
										<input type="hidden" name="_csrf" value="<@tools.csrfToken/>"/>
										<input type="hidden" name="contentId" value="${content.id!}"/>
										<input name="returnUrl" type="hidden" value="${site.dynamicPath}member/comment.html?contentId=${content.id!}" />
										<textarea name="text" maxlength="1000">${text!}</textarea>
										<input type="submit" value="提交"/>
									</form>
								</div>
								<@cms.commentList advanced=true userId=user.id contentId=content.id status=2>
									<#if page.totalCount gt 0>
										<h3>我的待审核评论</h3>
										<ul>
											<#list page.list as a>
											<@t.merge 'userIds' a.replyUserId!/>
											</#list>
											<@sys.user ids=t.userIds!><#assign userMap=map!/></@sys.user>
											<#list page.list as a>
											<li class="underline">
												<p>${a.createDate}<span class="float-right"><a href="comment.html?id=${a.id}&contentId=${a.contentId}">编辑</a></span></p>
												<#if a.replyId?has_content>
													<@cms.comment id=a.replyId>
														<p class="reply"><a href="${site.dynamicPath}member/user.html?id=${a.userId}" target="_blank">${userMap[a.userId?string].nickname}</a> : ${object.text!}</p>
													</@cms.comment>
												</#if>
												<p>${a.text!}</p>
											</li>
											</#list>
										</ul>
									</#if>
								</@cms.commentList>
							</#if>
						<#else>
							<div class="comment-text-box user-login">
								<div class="cover"><a href="${site.dynamicPath}member/login.html">登录后发布评论</a></div>
							</div>
						</#if>
						<@cms.commentList contentId=content.id pageIndex=pageIndex pageSize=10>
							<#list page.list as a>
								<@t.merge 'userIds' a.userId!/>
								<@t.merge 'userIds' a.replyUserId!/>
							</#list>
							<@sys.user ids=t.userIds!><#assign userMap=map!/></@sys.user>
							<#if page.totalCount gt 0>
								<h3>内容评论</h3>
								<ul>
									<#list page.list as a>
									<li class="underline">
										<p><a href="${site.dynamicPath}member/user.html?id=${a.userId}" target="_blank">${userMap[a.userId?string].nickname}</a> ${a.createDate?string('yyyy-MM-dd HH:mm')}<span class="float-right"><a href="${site.dynamicPath}member/comment.html?contentId=${content.id!}&replyId=${a.id}">回复</a></span></p>
										<#if a.replyId?has_content>
											<@cms.comment id=a.replyId>
												<p class="reply"><a href="${site.dynamicPath}member/user.html?id=${a.userId}" target="_blank">@${userMap[a.userId?string].nickname}</a> : ${object.text!}</p>
											</@cms.comment>
										</#if>
										<p>${a.text!}</p>
									</li>
									</#list>
								</ul>
							</#if>
							<#if page??>
							<div class="page">
								<#if !page.firstPage>
								<a href="${site.dynamicPath}member/comment.html?contentId=${content.id!}&pageIndex=${page.prePage}">上一页</a>
								<#else>
								<span>上一页</span>
								</#if>
								<#assign start=1/>
								<#if (page.pageIndex-5) gt start>
								<#assign start=page.pageIndex-4/>
								</#if>
								<#assign end=page.totalPage/>
								<#if (page.pageIndex+5) lt end>
								<#assign end=page.pageIndex+4/>
								</#if>
								<#if start gt 1>
								<a href="${site.dynamicPath}member/comment.html?contentId=${content.id!}&pageIndex=1">1</a> ...
								</#if>
								<#list start..end as n><a href="${site.dynamicPath}member/comment.html?contentId=${content.id!}&pageIndex=${n}"<#if n=page.pageIndex> class="selected"</#if>>${n}</a></#list>
								<#if end lt page.totalPage>
								... <a href="${site.dynamicPath}member/comment.html?contentId=${content.id!}&pageIndex=${page.totalPage}">${page.totalPage}</a>
								</#if>
								<#if !page.lastPage>
								<a href="${site.dynamicPath}member/comment.html?contentId=${content.id!}&pageIndex=${page.nextPage}">下一页</a>
								<#else>
								<span>下一页</span>
								</#if>
							</div>
							</#if>
						</@cms.commentList>
					</div>
				</div>
			</div>
		</div>
	</main>
	<script>
		var templatePath='${.current_template_name?keep_after('/')}';
	</script>
	<@tools.includePlace path="/cc29e896-332a-46d8-9bcb-d48e92144e9c.html"/> <#-- 尾部Footer -->
	<script type="text/javascript">
		$(function(){$('.login-form input').eq(0).focus();});
		function check(){
			if(!$('input[name=text]').val()){
				alert('评论不能为空');
				return false;
			}
			return true;
		}
	</script>
	 <script>
function star(contentId){
    $.getJSON('${site.dynamicPath}score/score?itemId='+contentId+'&itemType=content&_csrf=<@tools.csrfToken/>', function(data){
        location.reload();
    });
}
function unstar(contentId){
    $.getJSON('${site.dynamicPath}score/unscore?itemId='+contentId+'&itemType=content&_csrf=<@tools.csrfToken/>', function(data){
        location.reload();
    });
}
    </script>
</body>
</html>
